package com.hospital.payment.module.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisPlusConfig {

    /**
     * MybatisPlusInterceptor是一个组合式拦截器，除了分页拦截器之外还可以添加多个拦截器
     * 所有 MyBatis-Plus 的增强功能都通过统一的入口管理：
     分页功能：PaginationInnerInterceptor
     乐观锁：OptimisticLockerInnerInterceptor
     性能分析：IllegalSQLInnerInterceptor
     防止全表操作：BlockAttackInnerInterceptor
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
